package com.java2104.controller;

import com.java2104.entity.RCAttendance;
import com.java2104.service.RCAttendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/attendance")
public class AttendanceController {
    @Autowired
    private RCAttendanceService attendanceService;
    @GetMapping("/check")
    public void check() {}

    @PostMapping("/check")
    public String check(RCAttendance attendance) {
        attendanceService.save(attendance);//完成点名业务逻辑
        return "redirect:/attendance/index";
    }

    @GetMapping("/index")
    public void index() {}

    @RequestMapping("/list")
    @ResponseBody
    public List<RCAttendance> list(@RequestParam(defaultValue = "0") Integer userId,
                                   @RequestParam(defaultValue = "0") Integer classId) {
        return attendanceService.getList(classId, userId);
    }
}
